/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-06-11
 * Time: 20:56
 */
public class test2 {
    public int maxProfit(int[] prices) {
        int n = prices.length;
        if(n==1){
            return 0;
        }
        int maxProfitt = 0;
        int minPrice = prices[0];
        for(int i=1;i<n;i++){
            minPrice = Math.min(minPrice,prices[i]);
            maxProfitt = Math.max(maxProfitt,prices[i]-minPrice);
        }
        return maxProfitt;
    }
}
